package com.yzy.fly.entity.core;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yzy.fly.util.DateUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
@TableName(value = "fly_method", autoResultMap = true)
public class FlyMethod implements Serializable {
//    ,DataIncrement<Integer>
    @TableId(type = IdType.AUTO)
    private Integer id;
    private Integer seq;
    private String packageName;
    private String className;
    private String label;
    private String name;
    private String methodName;
    private String type;
    private String dataSource;
    private String databaseType;
    private String sqlContent;

    @TableField(value = "params",typeHandler = FastjsonTypeHandler.class)
    private JSONArray params = new JSONArray();
    private String returnClass;
    private Integer sqlId;
    private Integer classId;
    private Integer systemId;
    private String sqlDesc;
    private String descr;
    @DateTimeFormat(pattern= DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat( pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    private Date createTime;
    @DateTimeFormat(pattern= DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat( pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    private Date updateTime;

//    @Override
//    public boolean idSame(DataIncrement<Integer> item) {
//        if (null != id && (item.getId().intValue() == id.intValue() && -1 != item.getId().intValue() )) {
//            return true;
//        }
//        return false;
//    }
//
//    @Override
//    public void insert() {
//        FlySqlMapper flySqlMapper = SpringContextUtil.getBean("flySqlMapper");
//        flySqlMapper.insert(this);
//    }
//
//    @Override
//    public void update() {
//        FlySqlMapper flySqlMapper = SpringContextUtil.getBean("flySqlMapper");
//        flySqlMapper.updateById(this);
//    }
//
//    @Override
//    public void delete() {
//        FlySqlMapper flySqlMapper = SpringContextUtil.getBean("flySqlMapper");
//        flySqlMapper.deleteById(id);
//    }
}
